package com.hd123.rumba.gwt.widget2.client.form;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.PasswordTextBox;

/**
 * 实现了SourcesBeforeChangeEvents接口的PasswordTextBox
 * 
 * @author LiQi
 * 
 */
class RPasswordInput extends PasswordTextBox implements SourcesBeforeChangeEvents {

  private BeforeChangeListener beforeChangeListener;

  public void onBrowserEvent(Event event) {
    if (DOM.eventGetType(event) == Event.ONCHANGE && beforeChangeListener != null
        && !beforeChangeListener.beforeChange(this))
      return;
    super.onBrowserEvent(event);
  }

  public void setBeforeChangeListener(BeforeChangeListener listener) {
    this.beforeChangeListener = listener;
  }
}
